let search=window.location.search.split('=')[1]

if(search==undefined||search==''){
    let tagVessels=document.querySelector('.tagVessels')
    tagVessels.innerHTML+=`
        <div class="userEmpty">没有查到相关用户</div>
    `
}else{
    function userSearch(){
        return new Promise((reslove,reject)=>{
            axios({
                url:'/users/searchUserByName',
                params:{
                    userName:search
                }
            }).then(data=>{
                let message=data.data.key.data
                reslove(message)
            }).catch(err=>{
                reject(err)
            })
        })
    }
    userSearch().then(data=>{
        let tagVessels=document.querySelector('.tagVessels')
        console.log(data);
        if(data=="没有查到相关用户"){
            tagVessels.innerHTML+=`
                <div class="userEmpty">没有查到相关用户</div>
            `
        }else{
            for(let i=0,len=data.length;i<len;i++){
                let messagei=data[i]
                tagVessels.innerHTML+=`
                <div class="userVessels" onclick=toUser(${messagei.id})>
                    <!-- 头像 -->
                    <div class="userHeard" style="background-image: url(${messagei.portrait});"></div>
                    <!-- 昵称 -->
                    <table></table>
                    <div class="userName">${messagei.name}</div>
                    <!-- 简介 -->
                    <div class="des">${messagei.resume}</div>
                </div>
                `
            }
        }
    })
}

function toUser(id){
    window.location.href = `/picture/picture?userId=${id}`
}